package com.examples.layouts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

public class TreeWithTreeItem {

	public static void main(String[] args) {

		Display d = Display.getDefault();
		Shell s = new Shell(d);

		s.setSize(250, 200);

		s.setLayout(new FillLayout());
		final Tree tree = new Tree(s, SWT.SINGLE);

		TreeItem treeItem1 = new TreeItem(tree, SWT.NONE);
		treeItem1.setText("1");

		TreeItem treeItem2 = new TreeItem(tree, SWT.NONE);
		treeItem2.setText("2");

		TreeItem treeItem21 = new TreeItem(treeItem2, SWT.NONE);
		treeItem21.setText("21");

		TreeItem treeItem22 = new TreeItem(treeItem2, SWT.NONE);
		treeItem22.setText("22");

		TreeItem treeItem3 = new TreeItem(tree, SWT.NONE);
		treeItem3.setText("3");

		s.open();
		while (!s.isDisposed()) {
			if (!d.readAndDispatch())
				d.sleep();
		}

	}

}
